<template>
  <div class="header">
    <div class="logo">
      <img class="logo-img" :src="logo" alt="">
      <div class="logo-text">广州大学门诊部 自助缴费系统</div>
    </div>

    <div class="header-right">

    </div>
  </div>
</template> 
<script>
import bus from "@/utils/bus";
import logo from "@/assets/img/logo.png";
export default {
  data() {
    return {
      collapse: false,
      fullscreen: false,
      name: '管理员',
      logo: logo,
      message: 0,
      activeIndex: '0',
      authTreeList: [],
      max_number: 0
    };
  },
  computed: {
    username() {
      let userInfo = localStorage.getItem('userInfo');
      return userInfo ? JSON.parse(userInfo) : { realname: this.name };
    }
  },
  created() { },
  methods: {
    // 用户名下拉菜单选择事件
    handleCommand(command) {
      if (command == 'loginout') {
        const loading = this.$loading({ text: '退出中...' });
        this.$http.post(this.$API.LOGOUT, {})
          .then((res) => {
            loading.close();
            console.log('登录信息', res)
            if (res.code == 1) {
              window.sessionStorage.removeItem('userName')
              window.sessionStorage.removeItem('jqzxUserId')
              bus.$emit("global-close-open", false);
              this.$router.push('/login');
            } else {
              this.$message.error(res.msg);
            }
          })
          .catch((err) => {
            loading.close();
            this.$message.error('网络错误');
          })
      } else if (command == 'uploadUser') {//修改密码
        this.$router.push('/setPassword');
      }
    },
    // 侧边栏折叠
    collapseChage() {
      this.collapse = !this.collapse;
      bus.$emit('collapse', this.collapse);
    },
    // 全屏事件
    handleFullScreen() {
      let element = document.documentElement;
      if (this.fullscreen) {
        if (document.exitFullscreen) {
          document.exitFullscreen();
        } else if (document.webkitCancelFullScreen) {
          document.webkitCancelFullScreen();
        } else if (document.mozCancelFullScreen) {
          document.mozCancelFullScreen();
        } else if (document.msExitFullscreen) {
          document.msExitFullscreen();
        }
      } else {
        if (element.requestFullscreen) {
          element.requestFullscreen();
        } else if (element.webkitRequestFullScreen) {
          element.webkitRequestFullScreen();
        } else if (element.mozRequestFullScreen) {
          element.mozRequestFullScreen();
        } else if (element.msRequestFullscreen) {
          // IE11
          element.msRequestFullscreen();
        }
      }
      this.fullscreen = !this.fullscreen;
    },
  },
  mounted() {
    if (document.body.clientWidth < 1500) {
      this.collapseChage();
    }
  }
};
</script>
<style lang="less">
.header {
  position: fixed;
  box-sizing: border-box;
  width: 100%;
  height: 120*@hv;
  padding: 0 30*@wv;
  display: flex;
  align-items: center;
  justify-content: space-between;
  top:0;
  z-index: 10;
  .logo {
    display: flex;
    align-items: center;
  }
  .logo-img {
    height: 68*@hv;
    width: auto;
  }
  .logo-text {
    font-size: 40*@hv;
    margin-left:10*@wv;
    color:#fff;
  }
  .header-right {
    padding-right: 50*@wv;
    display: flex;
  }
}
</style>
